package edu.calvin.djs32.cs214.interpreters.acceptance;

import java.io.IOException;

import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.RecognitionException;

import edu.calvin.djs32.cs214.interpreters.calculator.CalculatorFactory;
import edu.calvin.djs32.cs214.interpreters.frontend.Hobbes2008FrontEnd;
import fit.Fixture;

public class ActionCalculator extends Fixture {

	  private String  myProgram;

	  public ActionCalculator() {
	    myProgram = "";
	  }

	  public void program(String line) {
	    myProgram += line + "\n";
	  }

	  public String calculation() throws RecognitionException, IOException {
		  return new Hobbes2008FrontEnd().process(new ANTLRStringStream(myProgram))
		  	.accept(new CalculatorFactory().createCalculator()).toString();
	  }
}